package top.korori.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.korori.common.model.PageData;
import top.korori.common.model.Result;
import top.korori.system.annotation.PreAuth;
import top.korori.system.entity.bo.SysOptLogBo;
import top.korori.system.service.SysOptLogService;
import top.korori.system.entity.vo.SysOptLogVo;

import java.util.List;


/**
 * 
 * 操作日志 前端控制器
 * 
 *
 * @author korori
 */
@Api(tags = "操作日志")
@RestController
@RequestMapping("/sys/optlog/")
public class SysOptLogController {

    @Autowired
    private SysOptLogService sysOptLogService;

    @ApiOperation("获取日志列表")
    @PreAuth("sys:optlog:list")
    @GetMapping("/list")
    public Result<PageData<SysOptLogVo>> list(SysOptLogBo sysOptLogBo){
        PageData<SysOptLogVo> sysOptLogs = sysOptLogService.list(sysOptLogBo);
        return Result.ok(sysOptLogs);
    }

    @ApiOperation("获取操作日志")
    @PreAuth("sys:optlog:query")
    @GetMapping("/get/{optLogId}")
    public Result<SysOptLogVo> get(@PathVariable Long optLogId){
        SysOptLogVo sysOptLogVo = sysOptLogService.get(optLogId);
        return Result.ok(sysOptLogVo);
    }

    @ApiOperation("删除操作日志")
    @PreAuth("sys:optlog:del")
    @DeleteMapping("/del/{optLogIds}")
    public Result<Void> del(@PathVariable List<Long> optLogIds){
        sysOptLogService.removeByIds(optLogIds);
        return Result.ok();
    }

}

















